﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Scripts.TDu3DWork
{
    class TDuFPSCameraWorker : MonoBehaviour
    {
        private CharacterController cc;  //控制器;
        public float speed;              //移动速度;

        // Start is called before the first frame update
        void Start()
        {
            cc = this.GetComponent<CharacterController>();
            speed = 100.0f;
        }

        // Update is called once per frame
        void Update()
        {
            //键盘移动;
            cc.Move(transform.forward * speed * Input.GetAxis("Vertical") * Time.deltaTime);
            cc.Move(transform.right * speed * Input.GetAxisRaw("Horizontal") * Time.deltaTime);

            //鼠标转向;
            if (Input.GetMouseButton(1))
            {
                if (Input.GetAxis("Mouse X") != 0)
                    gameObject.transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X") * Time.fixedDeltaTime * speed, 0));
                //if (Input.GetAxis("Mouse Y") != 0)
                    //gameObject.transform.Rotate(new Vector3(Input.GetAxis("Mouse Y") * Time.fixedDeltaTime * speed, 0, 0));
            }
        }
    }
}
